package com.dmooo.yxmmerchant.view.presenter;

import android.content.Context;

import com.common.mvpbase.BasePresenter;
import com.common.net.listener.HttpOnNextListener;
import com.dmooo.yxmmerchant.view.contract.PassWordContract;
import com.dmooo.yxmmerchant.view.model.PassWordModel;

public class PassWordPrestener extends BasePresenter<PassWordContract.PassWordView> implements PassWordContract.PassWordPtr {
    private PassWordModel model;
    public PassWordPrestener(PassWordContract.PassWordView mView, Context context) {
        super(mView);
        model=new PassWordModel(context);
    }

    @Override
    public void getPhoneCode(String token) {
        model.getPhoneCode(token, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.sendCodeSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void setDrawPwd(String token, String code, String pwd1, String pwd2) {
        model.setDrawPwd(token, code, pwd1, pwd2, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.setDrawPwdSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void userDrawMoney(String token, String account_type, String account, String money, String truename) {
        model.userDrawMoney(token, account_type, account, money, truename, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.drawMoneySuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void isSetDrawPwd(String token) {
        model.isSetDrawPwd(token, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
            }

            @Override
            public void onFail(Object o) {
                if(o.toString().contains("(1)")){
                    mView.noSetDrawPwd();
                }else{
                    mView.errorMsg(o.toString());
                }
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void checkDrawPwdCorrect(String token, String pwd) {
        model.checkDrawPwdCorrect(token, pwd, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.drawPwdCorrect();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }
}
